<template>
	<view class="box">
		<!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->
		<u--form labelWidth="150" labelPosition="left" :model="model1" :rules="rules" ref="uForm">
			<u-form-item label="请选择UP池" prop="upId" :borderBottom="true" ref="item1">
				<uni-data-select v-model="model1.upId" :localdata="ups"></uni-data-select>
			</u-form-item>
			<u-form-item label="请选择中奖车" prop="carsId" ref="item1">
				<uni-data-select v-model="model1.carsId" :localdata="cars"></uni-data-select>
			</u-form-item>
			<u-form-item label="" prop="name" ref="item1">
				<u-button text="提交" type="primary" shape="circle" @click="submit"></u-button>
			</u-form-item>

		</u--form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showSex: false,
				model1: {
					upId: '',
					carsId: ''
				},
				fileList1: [],
				groups: getApp().globalData.groups,
				maps: getApp().globalData.maps,
				ups: getApp().globalData.ups,
				cars: getApp().globalData.cars,
				rules: {
					'upId': {
						type: 'number',
						required: true,
						message: '请选择奖池',
						trigger: ['blur', 'change']
					},
					'carsId': {
						type: 'number',
						required: true,
						message: '请选择车辆',
						trigger: ['blur', 'change']
					},
				}
			};
		},
		onLoad() {
			this.getCars(0, () => {
				this.cars = getApp().globalData.cars
			})
		},
		methods: {
			submit() {
				this.$refs.uForm.validate().then(res => {
					this.$http('/api/upload/upReward', this.model1,'POST').then(r => {
						uni.$u.toast('上传成功')
						this.back(1, 1500)
					})
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
			}
		},
	};
</script>
<style lang="scss">
	:deep(.u-upload__wrap) {
		justify-content: flex-end !important;
	}
</style>